Skip to content

fix(sap-ai-core): normalize finish_reason and strip assistant prefill - #45320

Closed
Saichandra2520 wants to merge 1 commit into
anomalyco:devfrom
Saichandra2520:fix/sap-ai-core-prefill-and-loop
Closed

fix(sap-ai-core): normalize finish_reason and strip assistant prefill#45320
Saichandra2520 wants to merge 1 commit into
anomalyco:devfrom
Saichandra2520:fix/sap-ai-core-prefill-and-loop

Conversation

@Saichandra2520

@Saichandra2520 Saichandra2520 commented Aug 26, 2026

Copy link
Copy Markdown

Issue for this PR

Closes #45313
Closes #45314

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

  1. Strips trailing assistant messages in ProviderTransform.message for sap-ai-core models to resolve 400 errors with Claude models on SAP AI Core (which rejects assistant message prefill and requires conversations to end with a user message).
  2. Adds SSE stream response normalization in sap-ai-core provider options and SapAICorePlugin to map finish_reason: null to finish_reason: "stop", fixing the infinite loop with GPT models.

How did you verify your code works?

  • Added unit tests in packages/opencode/test/provider/transform.test.ts to test assistant message stripping.
  • Added unit tests in packages/opencode/test/provider/sap-ai-core.test.ts and packages/core/test/plugin/provider-sap-ai-core.test.ts to test finish_reason normalization.
  • Ran unit tests with bun test and verified all tests pass.
  • Ran tsgo --noEmit to verify type safety.

Screenshots / recordings

N/A (provider integration fix)

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

@github-actions github-actions Bot added the needs:compliance This means the issue will auto-close after 2 hours. label Aug 26, 2026
@github-actions

Copy link
Copy Markdown
Contributor

This PR doesn't fully meet our contributing guidelines and PR template.

What needs to be fixed:

  • PR description is missing required template sections. Please use the PR template.

Please edit this PR description to address the above within 2 hours, or it will be automatically closed.

If you believe this was flagged incorrectly, please let a maintainer know.

@github-actions

Copy link
Copy Markdown
Contributor

The following comment was made by an LLM, it may be inaccurate:

The search for "finish_reason null stop" found PR #43707 which is about chat streams, but that appears to be unrelated to the SAP AI Core provider issue.

Summary

No duplicate PRs found

The search results only return the current PR #45320 itself (which is correctly excluded from consideration) and one unrelated PR about console chat streams. There are no open PRs addressing the same SAP AI Core provider bugs regarding finish_reason normalization or assistant message prefill stripping.

@github-actions

Copy link
Copy Markdown
Contributor

This pull request has been automatically closed because it was not updated to meet our contributing guidelines within the 2-hour window.

Feel free to open a new pull request that follows our guidelines.

@github-actions github-actions Bot removed the needs:compliance This means the issue will auto-close after 2 hours. label Aug 26, 2026
@github-actions github-actions Bot closed this Aug 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants